package org.jwcloud.project.module.zx.workTime.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.jwcloud.project.module.zx.baseManager.service.repository.MatBaseManagerRepository;
import org.jwcloud.project.module.zx.common.FmtUtil;
import org.jwcloud.project.module.zx.common.Resp;
import org.jwcloud.project.module.zx.common.repository.RptCommonRepository;
import org.jwcloud.project.module.zx.common.service.RptUtService;
import org.jwcloud.project.module.zx.workTime.service.repository.MatWorkTimeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.github.pagehelper.PageHelper;
import com.jw.mid.mm.comm.common.controller.BaseController;
import com.jw.mid.mm.comm.common.controller.CrudController;
import com.jw.mid.mm.comm.common.json.Response;
import com.jw.mid.mm.comm.common.pagination.ListBounds;
import com.jw.mid.mm.comm.common.pagination.ListSlice;
import com.jw.mid.mm.comm.common.pagination.PageListSlice;
import com.jw.mid.mm.comm.common.pagination.Pagination;
import com.jw.mid.mm.comm.common.service.CrudService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

//@Api(value = "API - Controlle",
//description = "专项预警管理3个页面", tags = "workTime")
//@RestController
//@Transactional
//@RequestMapping("/rest/mat/workTime")
public class MatWorkTimeController extends BaseController{
	
	@Autowired
	public RptCommonRepository rptCommonRepository;
	
	@Autowired
	public MatBaseManagerRepository matBaseManagerRepository;
	@Autowired
	public MatWorkTimeRepository matWorkTimeRepository;
	
	@Autowired
    public RptUtService rptUtService;
	
	@RequestMapping("/view1")
	public ModelAndView testView(String param, ModelAndView model) {
		model.setViewName("/test/workTime/view1.html");
		return model;
	}
	
	@GetMapping("queryWorkList")
	@Deprecated
    @ApiOperation(value = "查询工作信息--/moon/rest/money/baseManager/queryWorkList", notes = "")
    @ApiImplicitParams({
    })
    public Resp queryItemList(
    		@RequestParam(required = false) Map<String,String> param
    		){
		return Resp.success(this.matBaseManagerRepository.queryWorkList(param));
    }
	
	@PostMapping("updateTipTime")
    @ApiOperation(value = "修改时效", notes = "")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "id", value = "id", required = false, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "tip_day", value = "提醒时限（工作日）", required = false, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "warn_first_day", value = "一次预警时限（工作日）", required = false, dataType = "string", paramType = "query"),
    	@ApiImplicitParam(name = "warn_second_day", value = "二次预警时限（工作日）", required = false, dataType = "string", paramType = "query"),
    	
    })
    public Resp updateTipTime(
    		@RequestBody(required = false) Map<String,String> param
    		){
		String flag = FmtUtil.nullRes(param
				, "id", "id");
		if(!StringUtils.isEmpty(flag)) 
			return Resp.error(flag);
		
		return Resp.success(this.matWorkTimeRepository.updateTipTime(param));
    }
	
}